#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define rep(i, x, y) for(int i = (x); i <= (y); i++) 
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using pii = pair < int , int >;

int read() {
	int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-', ch = getchar(); 
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar(); return f ? -x : x;
}

const int N = 5e5 + 10;

int n, K, mod, ans, id[N], pre[N], lst[N], cnt[N], ind[N], tot, lpos[N], pc[N];
pii l[N];

inline int upd(const int x) { return x + (x >> 31 & mod); }

namespace seg {
	int ch[N << 1][2], L[N << 1], R[N << 1], md[N << 1];
	int val[N << 1], ndn, rt;
	void pu(int o) { val[o] = 1ll * val[ch[o][0]] * val[ch[o][1]] % mod; }
	void build(int &o, int l, int r) {
		o = ++ndn; L[o] = l; R[o] = r; val[o] = 1; if(l == r) return; md[o] = (l + r) >> 1;
		build(ch[o][0], l, md[o]); build(ch[o][1], md[o] + 1, r); pu(o);
	}
	int pos, v;
	void upd(const int &o) {
		if(L[o] == R[o]) return val[o] = v, void();
		if(pos <= md[o]) upd(ch[o][0]); else upd(ch[o][1]); pu(o);
	}
	int xl, xr;
	int query(const int &o) {
		if(xl <= L[o] && R[o] <= xr) return val[o];
		int ans = 1;
		if(xl <= md[o]) ans = 1ll * ans * query(ch[o][0]) % mod;
		if(xr > md[o]) ans = 1ll * ans * query(ch[o][1]) % mod;
		return ans;
	}
	void init() { build(rt, 1, K); }
	void upd(const int &p, const int &val) { pos = p; v = val; upd(rt); }
	int query(const int &l, const int &r) { if(l > r) return 1; xl = l; xr = r; return query(rt); }
}

int f_pos(int lim) {
	int l = 1, r = K;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(::l[lpos[ind[mid]]].fi < lim) l = mid + 1;
		else r = mid - 1;
	} return l;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in, K = in, mod = in;
	rep(i, 1, n) l[i].fi = in, l[i].se = in;
	sort(l + 1, l + n + 1); seg :: init();
	per(i, n, 1) {
		if(!lpos[l[i].se]) ind[++tot] = l[i].se, lpos[l[i].se] = i;
		pre[i] = lst[l[i].se]; lst[l[i].se] = i;
	}
	reverse(ind + 1, ind + K + 1);
	rep(i, 1, K) id[ind[i]] = i;
	//rep(i, 1, K) cerr << ind[i] << " " << ind[id[i]] << " " << id[i] << endl, assert(ind[id[i]] == i);
	int cur = 1;
	rep(i, 1, K) {
		int x = ind[i]; //assert(id[x] == i);
		while(cur <= n && l[cur].fi * 2 <= l[lpos[x]].fi) {
			seg :: upd(id[l[cur].se], (++cnt[l[cur].se]) + 1);
			pc[l[cur].se] = cur;
			cur++;
		}
		int pre = seg :: query(1, i - 1), lim = pc[x] ? ::pre[pc[x]] : lst[x];
		lim = f_pos(l[lim].fi * 2);
		//cerr << lim << " " << pre << " " << tlim << endl;
		//cerr << " | " << x << " " << cnt[x] * pre << " " << " " << lim << " " << pre * seg :: query(i + 1, lim - 1) << " | " << endl;
		ans = upd(ans + 1ll * cnt[x] * pre % mod - mod);
		ans = upd(ans + 1ll * pre * seg :: query(i + 1, lim - 1) % mod - mod);
	} printf("%d\n", ans);
	return 0;
}
